package com.cpp.server.handler;

import com.cpp.common.exception.BaseException;
import com.cpp.common.result.Result;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(BaseException.class)
    public Result exceptionHandler(BaseException e, HttpServletRequest request){
        e.printStackTrace();
        return Result.error(e.getMessage());
    }
    @ExceptionHandler(Exception.class)
    public Result exceptionHandler(Exception e, HttpServletRequest request){
        e.printStackTrace();
        return Result.error(e.getMessage());
    }
}
